﻿using Api.Core.IRepository.Role;
using Api.Core.IServices.Role;
using Api.Core.IServices.User;
using Api.Core.Model.Role;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Api.Core.Services.Role
{
    public class RoleModuleInfoService : BaseService<RoleModuleEntity>, IRoleModuleInfoService
    {
        private readonly IUserRoleInfoService _userRoleInfoService;

        public RoleModuleInfoService(IRoleModuleRepository roleModuleRepository,
            IUserRoleInfoService userRoleInfoService)
        {
            _userRoleInfoService = userRoleInfoService;
            base.BaseDal = roleModuleRepository;
        }

        public async Task<List<RoleModuleEntity>> GetModuleIds(string userId)
        {
            var roleId = await _userRoleInfoService.GetRoles(userId);
            var model = await base.Query(x => x.RoleId == roleId);
            return model;
        }
    }
}
